package com.op.studyingliteapp.activity;

import java.lang.reflect.Field;

import android.app.ActionBar;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.ViewConfiguration;

import com.astuetz.PagerSlidingTabStrip;
import com.op.studyingliteapp.R;
import com.op.studyingliteapp.adapter.CoursePagerAdapter;
import com.op.studyingliteapp.sender.Runtime;

public class CourseActivity extends ScreenshotActivity {
	private String TAG = this.getClass().getSimpleName();
	private ViewPager pager;
	private PagerSlidingTabStrip tabs;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_course);
		setupPagerAndTabs();
		 setOverflowShowingAlways();
		ActionBar actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setDisplayShowHomeEnabled(false);
		actionBar.setDisplayShowTitleEnabled(true);
		actionBar.setTitle(""+getIntent().getStringExtra("CourseName"));//课程名称
	}
	private void setupPagerAndTabs() {
		pager = (ViewPager) this.findViewById(R.id.pager);
		Runtime.setView(pager);
		tabs = (PagerSlidingTabStrip) this.findViewById(R.id.tabs);
		pager.setAdapter(new CoursePagerAdapter(getSupportFragmentManager()));
		tabs.setViewPager(pager);
	}



	/**
	 * 解决overflow按钮的显示情况和手机的硬件情况是有关系的， 如果手机没有物理Menu键的话，overflow按钮就可以显示，
	 * 如果有物理Menu键的话，overflow按钮就不会显示出来
	 */
	private void setOverflowShowingAlways() {
		try {
			ViewConfiguration config = ViewConfiguration.get(this);
			Field menuKeyField = ViewConfiguration.class
					.getDeclaredField("sHasPermanentMenuKey");
			menuKeyField.setAccessible(true);
			menuKeyField.setBoolean(config, false);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	protected void onResume() {
		Log.i(TAG, "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
		super.onResume();
	}

//	private void getCourseName() {
//		SharedPreferences  preferences = getSharedPreferences("StudyingLite", Context.MODE_PRIVATE);
//		String getCourseId = preferences.getString(Common.Prefs.COURSE_ID, "");
//		String getUserId = preferences.getString(Common.Prefs.USER_ID, "");
//		
//		SeminarDao seminarDao = new SeminarDao(this, getUserId);
//		List<SeminarBean> seminar = seminarDao
//				.getSeminarByCourseId(getCourseId);
//		String CourseName =preferences.getString(Common.Prefs., defValue)
//	}
}
